import { postLoginWxminSimple, getMemberProfile } from '@/http/profile'

export default {
    namespaced: true,
    state: {
        profile: null,
        // 会员信息 单独请求接口 返回
        memberProfile: null,
    },
    getters: {},
    mutations: {
        setProfile(state, payload) {
            state.profile = payload
        },
        setMemberProfile(state, payload) {
            state.memberProfile = payload;
        },
    },
    actions: {
        async fetchProfile({ commit }, data) {
            const res = await postLoginWxminSimple(data)
            commit('setProfile', res.result)
        },
        // 异步 获取会员信息
        async fetchMemberProfile({ commit }) {
            const result = await getMemberProfile();
            commit("setMemberProfile", result.result);
            return result.result;
        },
    }
}